package com.wsoft.system.manager;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsoft.system.entity.TsDictDataEntity;
import com.wsoft.system.mapper.TsDictDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Zhang gukai
 * @Date 2024/8/29 15:50
 */
@Slf4j
@Service
public class DictDataManager extends ServiceImpl<TsDictDataMapper, TsDictDataEntity> {
    /**
     * 根据字典id获取子字典
     * @param id
     * @return
     */
    public List<TsDictDataEntity> getDataByDictId(Long id){
        QueryWrapper<TsDictDataEntity> query = new QueryWrapper<>();
        query.lambda().eq(TsDictDataEntity::getDictId,id);
        return list(query);
    }

    public List<TsDictDataEntity> getDataByCode(String code){
        QueryWrapper<TsDictDataEntity> query = new QueryWrapper<>();
        query.lambda().like(TsDictDataEntity::getCode,code);
        return list(query);
    }
}
